<?php
namespace app\index\controller;
use think\Db;
use think\Controller;

class Industry extends Controller
{
    //查询子分类
    public function select_catgory_result(){
        $id = input('parent_id');

        $result = db('industry_category')->where(['parent_id'=>$id])->select();

        $this->success($result);
    }

    //查询行业
    public function selects(){
    	$cid = 0;
    	$parent_id = input('parent_id');
    	$nav_id = input('nav_id');

    	if(empty($parent_id))$this->error('请选择父分类!');

    	//行业查询
    	if(empty($nav_id)){
    		//父分类
    		$cid = $parent_id;
    	}else{
    		$cid = $nav_id;
    	} 	

    	$where['cid'] = $cid;

    	$industry_category = db('industry')->where($where)->order('id desc')->select();


    	$this->success($industry_category);
    }
}
